<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
 <meta charset="utf-8">
 <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
 <title></title>
 <link rel="stylesheet" type="text/css" href="/assets/css/bootstrap.min.css">
 <link rel="stylesheet" type="text/css" href="/assets/fonts/line-icons.css">
 <link href="/assets/plugins/datatables/dataTables.bootstrap4.min.css" rel="stylesheet" type="text/css" />
 <link href="/assets/plugins/datatables/buttons.bootstrap4.min.css" rel="stylesheet" type="text/css" />
 <link href="/assets/plugins/datatables/responsive.bootstrap4.min.css" rel="stylesheet" type="text/css" />
 <link rel="stylesheet" type="text/css" href="/assets/css/main.css">
 <link rel="stylesheet" type="text/css" href="/assets/css/responsive.css">
    <link rel="stylesheet" href="/css/layui.css">
</head>
<body>
<div class="card-header border-bottom">
 <h4 class="card-title">电影/商品优惠活动展示</h4>
</div>
<div class="card-body">
 <div class="table-responsive">
  <table id="datatable" class="table table-bordered">
   <thead>
   <tr>
    <th>活动编号</th>
    <th>活动名称</th>
    <th>活动内容</th>
    <th>操作</th>
   </tr>
   </thead>
   <tbody>
   <tr th:each="t,line : ${ paSales.getItems() }">
       <td th:text="${t.id}"></td>
       <td th:text="${t.getName() }"></td>
       <td th:text="${ t.getContent() }"></td>
        <td th:id="${t.id}">
         <a class="modifySales" href="javascript:void (0)" th:target="_self">修改</a>
            <a class="buy" href="javascript:void (0)" th:target="_self">参与活动</a>
         <a class="deleteSales" href="javascript:void (0)" th:target="_self">删除</a>
        </td>
   </tr>
   <tr>
     <td colspan="10" id="jump">
       <a href="javascript:void (0)" class="btn btn-common">首页</a>
       <a href="javascript:void (0)" class="btn btn-common">上一页</a>
       <a href="javascript:void (0)" class="btn btn-common">下一页</a>
       <a href="javascript:void (0)" class="btn btn-common">尾页</a>
     </td>
   </tr>
   </tbody>
  </table>
 </div>
</div>
<script type="text/javascript" th:inline="javascript">

 var curr = [[${paSales.curr}]];
 var total = [[${paSales.total}]];

 if(curr == 1){
     $("#jump a:lt(2)").hide()
 }
 if(curr == total){
     $("#jump a:gt(1)").hide()
 }

   $("#jump a:eq(0)").bind("click",function () {
     toJump("/sales/querySales","curr="+1)
   })
  $("#jump a:eq(1)").bind("click",function () {
     toJump("/sales/querySales","curr="+[[${paSales.curr-1}]])
   })
  $("#jump a:eq(2)").bind("click",function () {
     toJump("/sales/querySales","curr="+[[${paSales.curr+1}]])
   })
  $("#jump a:eq(3)").bind("click",function () {
     toJump("/sales/querySales","curr="+[[${paSales.total}]])
   })

 // 编辑
 $(".modifySales").bind("click",function () {
     var id = $(this).parent().attr("id");
     alert(id);
     toJump("/sales/modifySales","id="+id)
 })

 // 参与活动
 $(".buy").bind("click",function () {
     var id = $(this).parent().attr("id");
     alert(id);
     if(!confirm("参与活动,您的商品则不能再参与退货服务,您确定参与吗?")) return
     toJump("/sales/choose1","id="+id)
 })

    //删除
    $(".deleteSales").bind("click",function () {
        var id = $(this).parent().attr("id");
        alert(id);
        if(!confirm("确定删除吗?")) return
     toJump("/sales/deleteSales","id="+id)
    })


</script>


<script src="/assets/js/jquery-min.js"></script>
<script src="/assets/js/popper.min.js"></script>
<script src="/assets/js/bootstrap.min.js"></script>
<script src="/assets/js/jquery.app.js"></script>
<script src="/assets/js/main.js"></script>
<script src="/assets/plugins/datatables/jquery.dataTables.min.js"></script>
<script src="/assets/plugins/datatables/dataTables.bootstrap4.min.js"></script>
<script src="/assets/plugins/datatables/dataTables.buttons.min.js"></script>
<script src="/assets/plugins/datatables/buttons.bootstrap4.min.js"></script>
<script src="/assets/plugins/datatables/jszip.min.js"></script>
<script src="/assets/plugins/datatables/pdfmake.min.js"></script>
<script src="/assets/plugins/datatables/vfs_fonts.js"></script>
<script src="/assets/plugins/datatables/buttons.html5.min.js"></script>
<script src="/assets/plugins/datatables/buttons.print.min.js"></script>
<script src="/assets/plugins/datatables/buttons.colVis.min.js"></script>
<script src="/assets/plugins/datatables/dataTables.responsive.min.js"></script>
<script src="/assets/plugins/datatables/responsive.bootstrap4.min.js"></script>
<script src="/js/layui.js"></script>
<script src="/js/layui.all.js"></script>
<script src="/ajax/jquery-1.8.3.js"></script>
<script src="/ajax/jump.js"></script>
</body>
</html>